#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

void ToLower(string &str)
{
    for (int i = 0; i < str.size(); i++)
        str[i] = tolower(str[i]);
}

class WordCount
{
private:
    string word;
    int count;

public:
    string getWord()
    {
        return word;
    }
    int getCount()
    {
        return count;
    }

    void setWord(const string &word)
    {
        if (this->word.compare(word) == 0)
        {
            // 字符串相等
            return;
        }
        this->word = word;
        count = 1;
    }

    void addCount()
    {
        count++;
    }
};

void CountWord(vector<WordCount> &vwc, const string &str)
{
    bool isExist = false;
    for (vector<WordCount>::iterator iter = vwc.begin(); iter != vwc.end(); iter++)
    {
        string word = iter->getWord();
        if (word.compare(str) == 0) // 字符串相等
        {
            isExist = true; // 存在
            iter->addCount();
            break;
        }
    }
    if (!isExist)
    {
        // 不存在
        WordCount wordCount;
        wordCount.setWord(str);
        vwc.push_back(wordCount);
    }
}

void DisplayResult(vector<WordCount> &vwc)
{
    // 获取最大值
    int max = 0;
    for (vector<WordCount>::iterator iter = vwc.begin(); iter != vwc.end(); iter++)
    {
        if (iter->getCount() > max)
        {
            max = iter->getCount();
        }
    }
    // 只输出最大值的单词
    for (vector<WordCount>::iterator iter = vwc.begin(); iter != vwc.end(); iter++)
    {
        if (iter->getCount() == max)
        {
            printf("%s %d\n", iter->getWord().c_str(), iter->getCount());
        }
    }
}

int main()
{
    vector<WordCount> vwc;
    string str;
    int i;
    while (cin >> str)
    {
        ToLower(str);
        CountWord(vwc, str);
    }
    DisplayResult(vwc);
    return 0;
}